package com.trinh.utils.crypto.enu;

import lombok.Getter;

/**
 * AES的加密算法
 * 用于 Cipher.getInstance(...) 参数传入
 *
 * @Author: TrinhRae
 * @Package: com.trinh.utils.crypto
 * @Project: generaltools
 * @Date: 2025/6/20 9:31
 */

public enum Algorithm {
    AES_ECB("AES/ECB", false),
    AES_CBC("AES/CBC", true),
    AES_CFB("AES/CFB", true),
    AES_OFB("AES/OFB", true),
    AES_CTR("AES/CTR", true),
    SM4_ECB("SM4/ECB", false),
    SM4_CBC("SM4/CBC", true),
    SM4_CFB("SM4/CFB", true),
    SM4_OFB("SM4/OFB", true),
    SM4_CTR("SM4/CTR", true),
    RSA_ECB("RSA/ECB", false),
    HMAC_MD5("HmacMD5", false),
    HMAC_SHA1("HmacSHA1", false),
    HMAC_SHA256("HmacSHA256", false),
    HMAC_SHA384("HmacSHA384", false),
    HMAC_SHA512("HmacSHA512", false);

    @Getter
    private final String mode;
    private final Boolean needIv;

    Algorithm(String mode, Boolean needIv) {
        this.mode = mode;
        this.needIv = needIv;
    }

    /***
     * 获取加密模式
     * @param padding 填充
     * @return
     */
    public String getTransformation(Padding padding) {
        return mode + "/" + padding;
    }

    public String getSignAlgo(){
        return mode;
    }

    public Boolean isNeedIv() {
        return needIv;
    }
}
